#include "stdafx.h"
#include "ErrorService.h"
#include "uconsole.h"

#include "MQNetServer.h"
#include "utimeutils.h"
#include "ucomhelper.h"

USING_LIBSPACE




CLogService::~CLogService()
{

}

bool CLogService::ReportError( TSSubSystem thetype,int errcode,const std::string& msg )
{
	UConsole::Print(UConsole::TEXT_RED,msg);

//WriteDetailLog(_T("MQError"),LogType::LTALL,msg);  WriteDetailLog(_T("stderr"),LogType::LTALL,msg);
	 CMQNetServer^ instance = CMQNetServer::Instance();
	 ErrorInfo info;
	 info.thetype = thetype;
	 info.errcode = errcode;
	 info.date = UTimeUtils::GetNowDate();
	 info.time = UTimeUtils::GetNowTime();
	 info.errmsg = msg;
	 bool ret = instance->publishErrorMsg(info);
	 return ret;
}

bool CLogService::ReportError( TSSubSystem thetype,int errcode,const std::wstring& msg )
{
	std::string amsg = UComHelper::ToAS(msg);
	bool ret = ReportError(thetype,errcode,amsg);
	return ret;
}
